package com.atguigu.res;

import lombok.Data;
import lombok.Getter;

@Getter
public enum ResultCodeEnum {
    SUCCESS(200,"成功"),
    FAIL(201, "失败"),
    UNAUTHORIZED(401, "未认证"),
    NOT_FOUND(404, "未找到"),
    INTERNAL_SERVER_ERROR(500, "服务器内部错误");

    private Integer code;
    private String message;

    ResultCodeEnum(Integer code, String message){
        this.code = code;
        this.message = message;
    }
    public static ResultCodeEnum getResultCodeEnum(Integer code){
        for (ResultCodeEnum codeEnum : ResultCodeEnum.values()) {
            if (codeEnum.getCode().equals(code)) //equalsIgnoreCase比较时忽略大小写
            {
                return codeEnum;
            }
        }
        return null;
    }
}
